package com.dxq.test.db;

import com.j256.ormlite.dao.ForeignCollection;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.field.ForeignCollectionField;
import com.j256.ormlite.table.DatabaseTable;

import java.io.Serializable;

/**
 * Author: zsh
 * Date: 2023/10/18
 * Describe: 饲喂表（字段）
 */
@DatabaseTable(tableName = "Feed")
public class Feed implements Serializable {

    public final static String ID_FIELD_NAME = "feed_id";

    // id = true:表明这个字段是这条记录的唯一标志符, generatedId = true:表明自动增加的ID
    //序号
    @DatabaseField(generatedId = true, columnName = ID_FIELD_NAME)
    private int feed_id;

    //饲喂编码
    @DatabaseField(columnName = "code")
    private String code;

    //饲喂时间
    @DatabaseField(columnName = "time")
    private String time;

    //所属牧场  牧场--外键
    @DatabaseField(columnName = "pasture_id", foreign = true, foreignAutoRefresh = true, foreignAutoCreate = true)
    private Pasture pasture_id;//序号

    //饲喂对应的分群
    @DatabaseField(persisted = false)//如果设置为false，表示这个字段不会写到数据库中
    private Group group;

    //饲喂对应的饲料
    @DatabaseField(persisted = false)//如果设置为false，表示这个字段不会写到数据库中
    private Food food;

    public Feed() {
    }

    public Feed(String code, String time, Pasture pasture_id) {
        this.code = code;
        this.time = time;
        this.pasture_id = pasture_id;
    }

    public int getFeed_id() {
        return feed_id;
    }

    public void setFeed_id(int feed_id) {
        this.feed_id = feed_id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public Pasture getPasture_id() {
        return pasture_id;
    }

    public void setPasture_id(Pasture pasture_id) {
        this.pasture_id = pasture_id;
    }

    public Group getGroup() {
        return group;
    }

    public void setGroup(Group group) {
        this.group = group;
    }

    public Food getFood() {
        return food;
    }

    public void setFood(Food food) {
        this.food = food;
    }

    @Override
    public String toString() {
        return "Feed{" +
                "feed_id=" + feed_id +
                ", code='" + code + '\'' +
                ", time='" + time + '\'' +
                ", pasture_id=" + pasture_id +
                ", group=" + group +
                ", food=" + food +
                '}';
    }
}
